<?php

namespace App\Models\admin;

use App\Models\BaseModel;

class AdminUserModel extends BaseModel
{
    protected $table = 'admin_user';
    protected $primaryKey = 'id';


    /**
     * 获取用户名
     * @param $admin_id
     * @return string
     */
    public static function getUserName($admin_id)
    {
        $user = self::find($admin_id);
        if ($user) {
            return $user->nickname;
        }
        return '';
    }

    public function role()
    {
        return $this->belongsTo(AdminRoleModel::class, 'role_id', 'id');
    }
}
